package com.his.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.his.struts.dao.hospitalInfo.HospitalInfoDao;
import com.his.struts.dao.hospitalInfo.HospitalInfoImp;
import com.his.struts.form.HospitalInfoForm;

/**
 * 医院信息
 * @author xiaoweiliang
 *
 */
public class HospitalInfoAction extends DiseaseAction {

	/** 
	 * Method execute 更新医院信息
	 * @param mapping 配置文件
	 * @param form 表单数据
	 * @param request 网页请求
	 * @param response 响应
	 * @return ActionForward 跳转医院信息页
	 */
	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HospitalInfoForm hospitalInfoForm = (HospitalInfoForm) form;
		HospitalInfoDao dao = new HospitalInfoImp();
		// 更新医院信息
		dao.updateHospitalInfo(hospitalInfoForm);
		// 读取医院信息
		HospitalInfoForm his = dao.getHospitalInfo();
		// 设置到全局
		this.getServlet().getServletContext().setAttribute("his", his);
		request.setAttribute("message", "修改成功");
		return mapping.getInputForward();
	}
}